package com.xlf.service.blog.controller;

import com.xlf.common.core.annotation.Anonymous;
import com.xlf.common.core.pojo.mode.AjaxResult;
import com.xlf.common.core.pojo.mode.BaseController;
import com.xlf.common.redis.service.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/blog/notice")
public class NoticeController extends BaseController {


    @Autowired
    RedisCache redisCache;

    private final static String NOTICE = "blog:notice";

    @PutMapping("/update")
    @PreAuthorize("@ss.hasPermi('blog:notice:update')")
    AjaxResult update(@RequestBody String text){
        redisCache.setCacheObject(NOTICE,text);
        return success();
    }


    @Anonymous
    @GetMapping("/query")
    AjaxResult query(){
        return success(redisCache.getCacheObject(NOTICE));

    }
}
